<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- 核心标签是最常用的JSTL标签 -->
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!-- 包含一系列标准函数,大部分 是通用的字符串处理函数 -->
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!-- 格式化并输出文本、日期、时间、数字 -->
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>竖版捕鱼房间 -- </title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="apple-mobile-web-app-title" content="Amaze UI" />
		<link rel="stylesheet" href="layui/css/layui.css">
		<link rel="stylesheet" href="css/fonts.css">
		<link rel="stylesheet" href="css/MyCSS.css">
		<!-- 适应所有设备 -->
		<style type="text/css">
			html,
			body {
				height: 100%;
				margin: 0;
				padding: 0;
			}

			.layui-form-label {
				width: 150px;
				font-size: 18px;
				text-align: left;
				padding-right: 0px;
				margin-right: 0px;
			}

			.layui-input-block {}

			.layui-nav {
				width: 40%;
				padding: 0px;
			}

			.layui-nav .layui-nav-item {
				width: 20%;
			}

			.layui-tab {
				height: 600px;
				overflow-y: auto;
				margin: 0px;
			}
			
			select:{
                width: auto;
                padding: 0 2%;
                margin: 0;
            }
            option{
                text-align:center;
            }
		</style>
	</head>
	<body>
		<br />
		<div class="layui-tab layui-tab-card" lay-filter="Fish_tabs" style="height:100%;">
			<ul class="layui-tab-title">
				<li class="layui-this" lay-id="1">初级房</li>
				<li lay-id="2">中级房</li>
				<li lay-id="3">高级房</li>
			</ul>
			<div class="layui-tab-content" >
				<div class="layui-tab-item layui-show">
					<jsp:include page="../room/sbby_public_tabs.jsp" flush="true"></jsp:include>
				</div>
			</div>
		</div>
		<br />
		
		<script type="text/html" id="IsBusinessman">
            {{#  if(d.IsBusinessman === false){ }}
                <span class="layui-badge layui-bg-green">玩家</span>
            {{#  } else if(d.IsBusinessman === true){ }}
                <span class="layui-badge layui-bg-blue">会长</span>
            {{#  } }}
        </script>
		
		<script type="text/html" id="playertable">
			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            {{#  if(d.IsBlocked == 0){ }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit">未锁定</a>
              {{#  } else { }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit2">已锁定</a>
              {{#  } }}
        </script>
        
        <script type="text/html" id="DifficultAllLevel">
            {{# if(d.WaterLine < d.WaterLineLimit[0]){ }}
                <span>很难</span>
            {{# }else if(d.WaterLine >= d.WaterLineLimit[0] && d.WaterLine < d.WaterLineLimit[1]){ }}
                <span>难</span>
            {{# }else if(d.WaterLine >= d.WaterLineLimit[1] && d.WaterLine < d.WaterLineLimit[2]){  }}
                <span>默认</span>
            {{# }else if(d.WaterLine >= d.WaterLineLimit[2] && d.WaterLine < d.WaterLineLimit[3]){  }} 
                <span>容易</span>
            {{# }else if(d.WaterLine >= d.WaterLineLimit[3]){ }}
                <span>极易</span>
            {{# } }}
        </script>
        
        <script type="text/html" id="RealGain">
            {{#  d.RealGain = d.TotalCurrencyWin - d.TotalCurrencyLost }}
                 <span>{{ d.RealGain }}</span>
            {{#  }}
        </script>
        
        <script type="text/html" id="LocationRoom">
            {{#  d.LocationRoom = d.LocationRoom + "-台子" + d.LocationPlatform}}
                 <span>{{ d.LocationRoom }}</span>
            {{#  }}
        </script>
		
		<script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script src="js/common/monitor_back.js"></script>
		<script type="text/javascript">
			layui.use(['layer', 'element', 'table', 'form'], function() {
				var layer = layui.layer,
					element = layui.element,
					table = layui.table,
					form = layui.form;
				layer.config({
					extend: 'MySkin/style.css'
				});
				
				table.render({
					elem: '#onlineTable',
					url: 'pa/onlinelist',
					method: 'post',
					title: '玩家资源变化',
					totalRow: true,
					autoSort: false,
					cellMinWidth: 50, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
					id: 'AllTable',
					request: {
						pageName: 'PageIndex',
						limitName: 'PageCount'
					},
					where: {
						Room : $('#Fish_Tabindex').val() == 1?"竖版捕鱼-房间1":$('#Fish_Tabindex').val() == 2?"竖版捕鱼-房间2":"竖版捕鱼-房间3",
						Businessman : 0
					},
					cols: [[
						{field: 'Id',title: 'ID'}, 
						{field: 'Nickname',title: '昵称'}, 
						{field:'IsBusinessman',title:'玩家/会长',templet:'#IsBusinessman',event:'setSign'},
						{field: 'LocationRoom',title: '所在游戏【房间】',templet:'#LocationRoom'},
						{field: 'LocationPlatform',title: '所在游戏【房间】台子',hide:true},
						{field: 'Currency',title: '携带金币',sort: true},
						{field: 'BankCurrency',title: '金库金币',sort: true}, 
						{field: 'TotalCurrencyLost',title: '总输',sort: true,hide:true}, 
						{field: 'TotalCurrencyWin',title: '总赢',sort: true,hide:true},
						{field: 'RealGain',title: '总输赢',sort: true,templet:'#RealGain'},
						{field:'LastLoginTime',title:'最后登陆时间'},
						{field:'LastLoginIp',title:'最后登录IP'},
						{field: 'IsBlocked',title: '封禁',hide:true}, 
						{field: 'CheatMode',title: '调整(数量/类型)',hide:true},
					    {title: '操作',fixed: 'right',width: 200,toolbar: '#playertable'}
						]],
					page: true, //分页
					response: {
						statusCode: 200
						//重新规定成功的状态码为 200，table 组件默认为 0
					},
					parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
						for (var i = 0; i < res.data.length; i++) {
							for (var key in res.data[i]) {
								if (res.data[i][key] == null) {
									res.data[i][key] == '无';
								}
							}
						}
						return {
							"code": res.status, //解析接口状态
							"msg": res.message, //解析提示文本
							"count": res.count, //解析数据长度
							"data": res.data //解析数据列表
							//解析数据列表
						};
					}
				});
				
				//table的渲染 
				var active = {
					reload: function() {
						//获取用户名
						//执行重载
						table.reload('AllTable', {
							page: {
								curr: 1 //重新从第 1 页开始
							}
							//根据条件查询
							,
							where: {
								UserId: $('#test').val(),
								Room: $('#Room').val(),
								Businessman : $('#Businessman').val()
							}
						});
						return false;
					}
				};
				$("#findID").on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});
          
				/* setInterval(function(){
		          	table.reload('Alltable2', {});
		          	table.reload('AllTable', {
		          		where: {
							Room : $('#Fish_Tabindex').val() == 1?"竖版捕鱼-房间1":$('#Fish_Tabindex').val() == 2?"竖版捕鱼-房间2":"竖版捕鱼-房间3",
							Businessman : 0
						}
		          	});
		          	
		          },60000); */
				
				//在线玩家
			    //监听行工具事件
				  table.on('tool(onlineTable)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
					  if (history.state == null){
						  pushHistory();
					  }
				  	var data = obj.data //获得当前行数据
				    ,layEvent = obj.event; //获得 lay-event 对应的值
				    if(layEvent === 'detail'){
				    	var id = data.Id;
				    	var Nickname = data.Nickname;
						var RegisterIp = data.RegisterIp;
						var LastLoginIp = data.LastLoginIp;
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: "查看玩家信息",
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playRecords',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index);
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".UserId").html(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zlastLoginIp").html(LastLoginIp);
								body.find("#nickname").html(Nickname);
								body.find("#RegisterIp").html(RegisterIp);
							},
							cancel:function () {
								window.history.back();
							}
						});
				    } else if(layEvent === 'adjust'){
				    	var id = data.Id;
						var name = data.Nickname;
						var currency = data.Currency;
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['1500px', '800px'],
							title: '调整玩家上下分',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playAdjustment',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id);
								body.find(".zname").val(name);
								body.find("#Currency").val(currency);
							},
							cancel:function () {
								window.history.back();
							}
				      });
				    } else if(layEvent === 'edit'){
				        var id = data.Id;
						var name = data.Nickname;
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: '锁定玩家',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playBlock',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index);
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zname").val(name);
							},
							cancel:function () {
								window.history.back();
							}
						});
				    }else if(layEvent === 'edit2'){
				    	var id = data.Id;
						var name = data.Nickname;
						var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['100%', '100%'],
							title: '解锁玩家',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/playUnBlock',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								// 取到弹出层里的元素，并把编辑的内容放进去
								body.find(".zid").val(id); //将选中的数据的id传到编辑页面的隐藏域，便于根据ID修改数据
								body.find(".zname").val(name);
								//parent.layer.close(index);//关闭子页面
							},
							cancel:function () {
								window.history.back();
							}
						});
				    }else if(layEvent === 'setSign'){
				    	var id = data.Id;
				    	var index = layer.open({
							type: 2,
							shadeClose: true,
							shade: 0.5,
							area: ['500px', '200px'],
							title: '设置会长',
							skin: 'layer-ext-yourskin',
							content: '<%=basePath%>pa/detail/setBusinessman',
							success: function(layero, index) {
								var body = layer.getChildFrame("body", index); //绑定父子页面
								body.find(".zid").val(id); 
							},
							cancel:function () {
								window.history.back();
							}
						});
				    }
				  });	
				
				
				table.on('tool(difficult)', function(obj) {
					if (history.state == null){
						pushHistory();
					}
					var str = '<div class="layui-inline" style="margin-left:35%;margin-top:5%;">' +
						'<label"><strong>难度选择</strong></label>' +
						'<div class="layui-input-inline">' +
						'<select name="select_difficult" id="select_difficult" lay-filter="select_difficult" style="width:100px;background:#009688;color:white;">' +
						'</select>' +
						'</div>' +
						'</div>';
					var data = obj.data;
					if (obj.event == 'pump') {
						var ServerId = $('#ServerId option:selected').val();
						var ConfigId = $('#Fish_Tabindex').val();
						var PlatformId = data.PlatformId;
						var WaterLineLimit = data.WaterLineLimit;
						layer.confirm('<div style="text-align:center;margin:0 auto;"><h2>修改值<br/><span style="color:red;">大于0放水</span><br/><sapn style="color:red;">小于0抽水</span><br/><sapn style="color:red;">水位或彩金不能填0</span><br/></h2></div>',{
							btn:['我已了解','退出']//按钮
						},function(index){
			    			var index = layer.open({
								type: 2,
								shadeClose: true,
								shade: 0.5,
								area: ['1200px', '400px'],
								title: '修改水位|彩金池',
								skin: 'layer-ext-yourskin',
								content: '<%=basePath%>room/toSetRoom',
								success: function(layero,index,resp) {
									var body = layer.getChildFrame("body",index);
									body.find(".ServerId").val(ServerId);
									body.find(".ConfigId").val(ConfigId);
									body.find(".GameId").val(1);
									body.find(".SiteId").val(1);
									body.find(".PlatformId").val(PlatformId);
								},
								cancel:function () {
									window.history.back();
								}
							});
						},function(){
						});
					}
					return false;
				});


				//监听选项卡切换
				element.on('tab(Fish_tabs)', function(data) {
					document.getElementById('Fish_Tabindex').value = data.index + 1;
					table.reload('Alltable2',{
		                page : {
		                  cuur : 1
		                },
		                where:{
		                  ServerId:$('#ServerId option:selected').val(),
		                  ConfigId:$('#Fish_Tabindex').val(),
		                  GameId:1,
		                  SiteId:1
		                }
		              });
					table.reload('AllTable', {
						where: {
							Room : $('#Fish_Tabindex').val() == 1?"竖版捕鱼-房间1":$('#Fish_Tabindex').val() == 2?"竖版捕鱼-房间2":"竖版捕鱼-房间3",
							Businessman : 0
						}
					})
					return false;
				});


			});
		</script>
		<script type="text/html" id="tool">
            <a class="layui-btn layui-btn-xs" lay-event="pump">抽水</a>
        </script>
	</body>
</html>
